#include "charlist.h"

void create_CharList(Element *charA, const Element charB)
{
  char **a = (char **)charA;
  char *b = (char *)charB;
  (*a) = (char *) malloc((strlen(charB) + 1) * sizeof(char));
  strcpy((*a), b);
}

void destroy_CharList(Element *charA)
{
  char **a = (char **)charA;
  free((*a));
  (*a) = NULL;
}

ListReturn compare_CharList(const Element charA,
                            const Element charB)
{
  char *a = (char *)charA;
  char *b = (char *)charB;
  ListReturn ret;
  switch(strcmp(a, b))
    {
    case -1 :
      ret = LIST_COMP_DIF;
      break;
    case 0 :
      ret = LIST_COMP_EQ;
      break;
    case 1 :
      ret = LIST_COMP_DIF;
      break;
    default :
      ret = LIST_ERR;
      break;
    }
  return ret;
}

void print_CharList(const Element charA)
{
  char *a = (char *)charA;
  printf("%s\n", a);
}
